|
|
|
CAUTION
|
|
|
|
|
This code will only work if all controls on the form support the Font property. A few controls, such as the Timer control, don't have that property. |
|
|
|
|
|
|
|
|
|
|
You can use the same approach with any other properties that are supported by all the controls on the form. |
|
|
|
|
|
|
|
|
Changing Selected Controls |
|
|
|
|
|
|
|
|
What if you want to set a property that is not supported by all the form's controls? For example, if you want to change the text color of your controls, the command button doesn't have a ForeColor property, although other types of controls do. For this problem, you use another code statement: the TypeOf statement. This statement allows you to determine the type of any object. This way, you can set up a routine that changes the ForeColor property of all controls that are not command buttons: |
|
|
|
|
|
|
|
|
For Each Control In Form1.Controls
If Not TypeOf Control Is CommandButton Then
Control.ForeColor = &HFF
End If
Next Control |
|
|
|
|
|
|
|
|
This chapter introduced you to the world of forms and controls. You learned how to control the appearance of forms and controls through their properties and how you can use the methods of forms to perform tasks. You also saw how to work with multiple controls in both the design environment and in your programs. |
|
|
|
|
|
|
|
|
For more information on topics discussed in this chapter, see the following: |
|
|
|
|
|
|
|
|
To learn about some controls other than the standard controls, see Chapter 6, "Giving More Control to the User: Menus and Toolbars," and Chapter 12, "Microsoft Common Controls." |
|
|
|
|
|
|
|
|
To learn about using controls in an array, see Chapter 13, "Working with Control Arrays." |
|
|
|
|
|
|
|
|
To find out how to arrange controls in a manner that is visually pleasing, as well as learn about some graphics-related controls, see Chapter 19, "Using Visual Design Elements." |
|
|
|
|
|